<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
	$(function() {
		var url = location.search;
		var str = url.substr(5);
		//alert(str);
		selectBook(str);
		$("#btn").click(function(){
			var bid=str;
			var bname=$("#bname").val();
			var count=$("#count").val();
			var author=$("#author").val();
			var outdate=$("#outdate").val();
			var price=$("#price").val();
			var output=$("#output").val();
			var description=$("#description").val();
			var flag=$("#flag").val();
			
			var json={"bid":bid,
					"bname":bname,
					"count":count,
					"author":author,
					"outdate":outdate,
					"price":price,
					"output":output,
					"description":description,
					"flag":flag};
			$.ajax({
				url:"book/update",
				type:"post",
				data:JSON.stringify(json),
				contentType:"application/json;charset=utf-8",
				success:function(result){
					alert(result);
					window.location.reload();
				}
			})
		}) 

	})
	function selectBook(bid) {
		var fbid = bid;
		$.ajax({
			url : "book/book",
			type : "get",
			data : {
				"bid" : fbid
			},
			dataType : "json",
			success : function(result) {
				//alert(result)
				$("#book").append(
						"<tr><td>" + result.bid + "</td>" 
						+ "<td>"+ result.bname + "</td>" 
						+ "<td>"+ result.count + "</td>" 
						+ "<td>"+ result.author + "</td>" 
						+ "<td>"+ result.outdate + "</td>" 
						+ "<td>"+ result.price + "</td>" 
						+ "<td>"+ result.output + "</td>" 
						+ "<td>"+ result.description + "</td>" 
						+ "<td>"+ result.flag + "</td></tr>"

				)
			}
		});

	}
</script>
<title>Insert title here</title>
</head>
<body>

	<table class="table table-bordered table-hover table-condensed">
		<thead>
			<tr>
				<th>书籍编号</th>
				<th>书名</th>
				<th>数量</th>
				<th>作者</th>
				<th>出版时间</th>
				<th>价格</th>
				<th>出版社</th>
				<th>描述</th>
				<th>状态</th>
			</tr>
		</thead>
		<tbody id="book"></tbody>
	</table>
	<br/><br/><br/><br/><br/>		
	<form id="info" >	
  	书本名称：<input type="text" name="bname" id="bname"><br/>	
  	书本入库数量：<input type="text" name="count" id="count"><br/>
           作者：<input type="text" name="author" id="author"><br/>
  	出版日期：<input type="text" name="outdate" id="outdate"><br/>
  	价格：<input type="text" name="price" id="price"><br/>
  	出版社：<input type="text" name="output" id="output"><br/>
  	书籍描述：<input type="text" name="description" id="description"><br/>
  	书本状态：<input type="text" name="flag" id="flag"><br/>
  		
  </form>
  <button id="btn">提交</button>
  <a href="manage.jsp"><button id="btn" >返回主页</button></a>
</body>
</html>